﻿<?
include("common/header.html");
include("common/left.html");
$allow = include '/var/www/html/new/d/qunar/export_array.php';
// $allow = array(100019);
if(!in_array($_SESSION['account'],$allow) && !$_GET['p'])exit('请联系管理员获得权限');
include_once("class/Member.php");
include_once("class/ProOrder.php");
$ac=$GLOBALS['_ac'];
$pw=$GLOBALS['_pw'];
$s = new SoapClient(null,array("location" => "http://localhost/open/openService/pft_insideMX.php","uri" => "www.16u.com?ac_16u=$ac|pw_16u=$pw|auth_16u=true"));

$did = $_SESSION['memberID'];
$memberID=$_SESSION['sid'];
$m=new Member($s,$memberID);
$salePros=$m->salePros();
$sortType='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
$lands = $save = $ticket = $tickets =  array();

// print_r($salePros);
// exit;
for($i=0;$i<strlen($sortType);$i++){
	foreach($salePros as $k=>$data){
		// 新数组 key 
        
        $akeys = $data['lid'].'_'.$data['sapply_did'];
        
		if($sortType[$i]==$data['py'] && $data['pay'] == 1){			
            if(!isset($lands[$akeys])){ // 景区数据，没有才添加
                $tmp = array(
                    'title'=>$data['title'],
					'sapply_did'=>$data['sapply_did']
                );
                $lands[$akeys] = $tmp;
            }
            // 放门票
            $ticket = array(
				'tid' => $data['tid'],
                'ttitle' => $data['ttitle'],
                'sapply_did'=>$data['sapply_did'],
            );
            $lands[$akeys]['ticket'][]=$ticket;
            $tickets[$akeys][$data['tid']]=$data['ttitle'];            
            
             
		}		
	}	
}
// print_r($tickets);exit; 
?>
<script type="text/javascript">

function getvalue(obj){
	var lidvalue = $(obj).val();
    $(".tiks").hide().removeAttr("name").removeAttr("id");
	$(".tiks").each(function(index,element){
        if($(element).attr("data")==lidvalue){
            $(element).css("display","block").attr("name","tvalue").attr("id","ticketSelect");
        }
    });
}
</script> 
<script src="js/WdatePicker.js"></script>
<script src="js/select2.js"></script>
<script src="js/Calendar.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="css/select2.css">
<style>
.centent{ width:790px;  margin:3px 0 0 34px;font: 12px/1.5 "Microsoft YaHei",微软雅黑,"Microsoft JhengHei",华文细黑,STHeiti,MingLiu,宋体;
}
.cance{   margin:3px 0 0 34px;font: 15px/1.5 "Microsoft YaHei",微软雅黑,"Microsoft JhengHei",华文细黑,STHeiti,MingLiu,宋体;
}
#tabna{float:left;margin-top: 15px;}
#landSelect{ font-size:14px;background-color:#f5f5f5;border: 1px solid #e5e5e5;height:30px;width:214px;}
td{padding-top:10px;padding-right: 10px;}
.wod1{font-size:14px;}
.clear{float:none;}
.radio{margin-top:5px;}
.title{font: 1.2em "Microsoft YaHei",微软雅黑,"Microsoft JhengHei",华文细黑,STHeiti,MingLiu,宋体;}
.input_a{background-color:#f5f5f5;border: 1px solid #e5e5e5;height:30px;width:214px;}
.input_b{background-color:#f5f5f5;border: 1px solid #e5e5e5;height:30px;width:214px;}
.input_c{background-color:#f5f5f5;height:30px;width:216px;}
.input_d{background-color:#f5f5f5;border: 1px solid #e5e5e5;height:30px;width:216px;}
.anniu{position:absolute;margin-top: 340px;<!-- margin-left: 160px; -->}
.centent .anniu a:link{text-decoration: none; color:#FCFCFC;}
.centent .anniu a{text-decoration: none; color:#FCFCFC;}
.centent .anniu .bottomg{ width: 100px;height: 30px;float: right;
margin-right: 10px;line-height: 30px;border: 0;font-size: 1.4em;background-color: #00a0e9;text-align:center;
font-weight:normal;color: #FFF;margin-top:10px; cursor: pointer;}
.centent .anniu .botwod1{ background:#089CE1;color:#FFF;}
.centent .anniu .botwod2{ background:#EF8A1D;color:#FFF;}
.out{ margin:20px; border:1px solid #aaa}
.cancel_div{float:left;}
.cancel_Y{width: 100px;height: 30px;float: right;
line-height: 30px;border: 0;font: 1.4em "Microsoft YaHei",微软雅黑,"Microsoft JhengHei",华文细黑,STHeiti,MingLiu,宋体;background-color: #EF8A1D;
font-weight:normal;color: #FFF;margin-top:10px; cursor: pointer;}
.cancel_N{width: 100px;height: 30px;float: left;
margin-right: 3px;margin-top:10px;line-height: 30px;border: 0;font:1.4em "Microsoft YaHei",微软雅黑,"Microsoft JhengHei",华文细黑,STHeiti,MingLiu,宋体;background-color:#00a0e9;
font-weight: normal;color: #FFF;cursor: pointer;}
#cancel_table{float:left;margin-left:33px;}
span.span_t{font: 1.2em "Microsoft YaHei",微软雅黑,"Microsoft JhengHei",华文细黑,STHeiti,MingLiu,宋体;}
.chkbtn {background-color:#019be1;color:#fff; border:0;font: 1.4em "Microsoft YaHei",微软雅黑,"Microsoft JhengHei",华文细黑,STHeiti,MingLiu,宋体;width:70px;height:28px;text-align:center;}
</style> 
<div class="r_content" id="bind_tao">
    <h3 class="mc_title">
			<span class="mctit_1"><a href="exportCode.html"><span class="mctit_2">团购导码</span></a></span>
	</h3>
<div class="centent">
<form action="/call/exportCode.php" method="post" name="form_export">
<table id="tabna" align="center">
    <tr> 
        <td class="wod1">景区名称：</td>
        <td>
            <select id="landSelect" style="width:214px;"class="sela input_c" name="Tlid" onchange="getvalue(this)" >
                <option value="">请选择景区</option>
                <?foreach($lands as $k => $v){?>
                    <option value="<?=$k?>"><?=$v['title']?></option>
                <?}?>
            </select>
        </td>
    </tr>
	<script>
		$("#landSelect").select2({
			placeholder: "Select a State",
			allowClear: true
		});
	</script>
    <tr>
        <td class="wod1" >门票名称：</td>
		<td>
            <?foreach($tickets as $k =>$v):?>
            <select class="tiks input_d"  name="Ttida" data="<?=$k?>"  style="display:none;">
                <?foreach($v as $tid=>$ttile){?>
                <option value="<?=$tid?>"><?=$ttile?></option>
                <?}?>
            </select>
            <?endforeach;?>
        </td>
    </tr>
    <!--开始时间-->
    <tr class="time">
        <td class="wod1">游玩时间：</td>
        <td>
            <input type="text" id="begintime" data-t="bt" id="btn2" data-msg="请选择时间段" value="<?=substr($data['order_play'],0,10)?>"  name="order_play" class="required input-text w66 input_a"  onfocus="WdatePicker({minDate:'%y-%M-{%d}'})"/>
            <a href="#"></a>
        </td>
		<!-- <i class="calendarBtn c1"></i> -->
    </tr>
	<tr> 
        <td class="wod1">团购姓名：</td>
        <td><input type="text" id="tgname" class="tgname input_a" name="tgname" /> (比如：一元活动导码)</td>
    </tr>
	<tr> 
        <td class="wod1">供应商ID：</td>
        <td><input type="text" id="aid" class="aid input_a" name="aid" />（选填）</td>
    </tr>
    <tr> 
        <td class="wod1">订单总数：</td>
        <td><input type="text" id="tnum" class="numorda input_a" name="Tnum" /> 单</td>
    </tr>
    <tr>
        <td class="wod1">每单票数：</td>
        <td><input type="text" id="tpnum" class="numorda_d input_a" name="Tpnum" /> 张</td>
    </tr>
	<tr>
        <td class="wod1">支付方式：</td>
        <td>
			<input type="radio" name='pay' class="radio" value=0 />
			<span class="span_t">账户余额支付</span>
			<input type="radio" name='pay'  class="radio" value=2 checked="checked" />  
			<span class="span_t">供应商授信支付</span>
		</td>
    </tr> 
	<tr>
        <input type="hidden" name="echo_t" id="Tmode" />
    </tr>
	<div class="anniu">
      <!--  <a href="#" class="bottomg output" id="0" >屏幕输出</a>  -->
        <a href="#" class="botwod1 bottomg output" id="1" >TXT导出</a>
        <a href="#" class="botwod2 bottomg output" id="2" >Excel导出</a>
    </div>  

</table>
</form>
</div>

<div class="cancel_div">
<hr style="width:700px;margin-top:80px;border:1px #e1e1e1 solid;">
<form action="/call/exportCode_cancel.php" method="post" name="form">
	<table id="cancel_table" align="left">
		<tr> 
			<td class="cance">取消的订单号:</td>
			<td class="title"><input type="text" id="order" class="order input_b" name="order" />（多个请用逗号隔开。注：是订单号。）</td>
		</tr>
		<tr>
			<td>
			<input type="submit" id="cancel_Y" class="cancel_Y" name="cancel_Y" value="提交" />
			</td>
			<td>
			<input type="reset" id="cancel_N" class="cancel_N" name="cancel_N"value="重置" />
			</td>
		
		</tr>
	</table>	
</form>
</div>
<script>
$("#cancel_Y").click(function(){
	if(!$("#order").val()){
		alert("请输入凭证码");
		return false;
	}
})
$("a.output").click(function(){
	if(!$("#landSelect").val()){
		alert("请选择景区");
		return false;
	}	

	if($("#lowerSelect").size()>0&&!$("#lowerSelect").val()){
		alert("请选择下级分销商");
		return false;
	}
	
	if(!$("#begintime").val()){
		alert("请选择填写游玩时间");
		return false;
	}	
	if(!$("#tgname").val()){
		alert("请填写团购姓名，以便区分");
		return false;
	}
    <?php if(!$_GET['nolimit']):?>
	if(!$("#tnum").val()||isNaN($("#tnum").val())||$("#tnum").val()<0 ||$("#tnum").val()>500){
		alert("请填写有效订单总数,且不能大于500,如大于500,请分批导码");
		return false;
	}
    <?php endif;?>
	if(!$("#tpnum").val()||isNaN($("#tpnum").val())||$("#tpnum").val()<0){
		alert("请填写有效每单票数");
		return false;
	}
	var id=$(this).attr("id");
	$("#Tmode").val(id);
	var sup = $(this).attr("data");
	var text="确定要提交?"+
	"\n景区名称："+$("#landSelect").find("option:selected").text()+
	"\n门票名称："+$("#ticketSelect").find("option:selected").text()+
	"\n游玩时间："+$("#begintime").val()+
	"\n团购姓名："+$("#tgname").val()+
	"\n供应商ID："+$("#aid").val()+
	"\n订单总数："+$("#tnum").val()+
	"\n每单票数："+$("#tpnum").val()
	if(confirm(text)){
		document.forms['form_export'].submit();
		// $(".anniu").hide();
	}
	return false;
})
</script>
</div>
<?php if($_GET["debug"]==1):?>
    <link rel="stylesheet" type="text/css" href="http://www.12301.cc/css/common/reset_style.css"/>
    <link rel="stylesheet" href="http://www.12301.cc/css/new/exportCode.css"/>
<?php endif;?>
<?include("common/footer.html");?>
